<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>
    
    ES7 新特性 - DSRBLOG
    
  </title>
  

  
  
  <link href="atom.xml" rel="alternate" title="DSRBLOG" type="application/atom+xml">
  <link rel="stylesheet" href="asset/css/style.min.css">
  <link rel="stylesheet" href="asset/css/doc.css">
  <script src="asset/app.js"></script>


</head>

<body> <section class="ct-body">
	<div class="container">
		<div class="columns is-variable bd-klmn-columns is-4 is-centered">
			<div class="column is-four-fifths">
				<div class="post-body single-content">
					
					<h1 class="title">
						ES7 新特性
					</h1>


					<div class="media">
						
						
						<div class="media-content">
							<div class="content">
								<p>
									<span class="date">2022/10/21 21:58 下午</span>
									

									

									<br />
									<span class="tran-tags">Tags:</span>&nbsp;
									
									<a class="tag is-link is-light">#ES7-11</a>
									

								</p>
							</div>
						</div>

					</div>
				</div>
				<article class="markdown-body single-content">
					<h2><a id="array-prototype-includes" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>Array.prototype.includes</h2>
<p><code>Includes</code>方法用于检测数组中是否包含某个元素，返回<code>boolean</code>类型值</p>
<pre class="line-numbers"><code class="language-js">const book = ['西游记', '红楼梦', '三国演义', '水浒传'];

console.log(book.includes('西游记')); //输出 true
console.log(book.includes('海贼王')); //输出 false
</code></pre>
<h2><a id="%E6%8C%87%E6%95%B0%E6%93%8D%E4%BD%9C%E7%AC%A6" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>指数操作符</h2>
<p><code>ES7</code>中引入指数运算符<code>**</code>，用于实现幂运算，功能与<code>Math.pow</code>结果相同</p>
<pre class="line-numbers"><code class="language-js">console.log(2**10); //2的十次方，输出 1024
</code></pre>
<p>等同于</p>
<pre class="line-numbers"><code class="language-js">console.log(Math.pow(2, 10));
</code></pre>

				</article>
				<div class="comments-wrap">
					<div class="share-comments">
						

						

						
					</div>
				</div><!-- end comments wrap -->
			</div>
		</div><!-- end columns -->
	</div><!-- end container -->
</section>  














<script src="asset/prism.js"></script>









</body>

</html>